
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.JSInterop;

using MyDocuments.Client;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(async sp => {
    var js = sp.GetService<IJSRuntime>();
    var value = await js.InvokeAsync<string?>("localStorage.getItem", "token");
    var httpclient = new HttpClient
    {
        BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
    };
    httpclient.DefaultRequestHeaders.Add("token", value);
    return httpclient;

} );
builder.Services.AddAntDesign();
Constants.BaseAddress = builder.HostEnvironment.BaseAddress;

await builder.Build().RunAsync();